package com.qingke.login;

import java.io.InputStream;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class LoginDao {
	static {
		try {
			Class.forName("org.apache.ibatis.session.SqlSessionFactoryBuilder");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			System.out.println("not fount builder");
		}
	}

	public static SqlSession getMybatisSession() {
		String resource = "mybatis_conf.xml";
		InputStream is = LoginDao.class.getClassLoader().getResourceAsStream(resource);
		SqlSessionFactory sessionFactor = new SqlSessionFactoryBuilder().build(is);
		SqlSession session = sessionFactor.openSession();
		return session;
		
	}
	
}
